package com.tbit.main.service.impl;

import com.tbit.main.constant.DaoParamConstant;
import com.tbit.main.dao.core.VipLogDao;
import com.tbit.main.pojo.KVEntity;
import com.tbit.main.pojo.VipSta;
import com.tbit.main.service.VipLogService;
import com.tbit.main.util.DateTimeUtil;
import com.tbit.main.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * vip会员
 *
 * @author Leon
 * 2020年9月3日 下午3:55:06
 */
@Service("vipLogService")
public class VipLogServiceImpl implements VipLogService {
    @Autowired
    private VipLogDao vipLogDao;

    @Override
    public VipSta staByTime(Integer accountId, String startTime, String endTime) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(DaoParamConstant.accountId, accountId);
        params.put(DaoParamConstant.startTime, startTime);
        params.put(DaoParamConstant.endTime, endTime);
        return vipLogDao.staByTime(params);
    }

    @Override
    public List<KVEntity> vipCountGroupByDate(Integer accountId, String startTime, String endTime) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(DaoParamConstant.accountId, accountId);
        params.put(DaoParamConstant.startTime, startTime);
        params.put(DaoParamConstant.endTime, endTime);

        return vipLogDao.vipCountGroupByDate(params);
    }

    @Override
    public List<KVEntity> vipMoneyGroupByDate(Integer accountId, String startTime, String endTime) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(DaoParamConstant.accountId, accountId);
        params.put(DaoParamConstant.startTime, startTime);
        params.put(DaoParamConstant.endTime, endTime);

        return vipLogDao.vipMoneyGroupByDate(params);
    }

    @Override
    public Integer getByAccountIds(List<Integer> accountIds) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(DaoParamConstant.accountIds, StringUtil.getListString(accountIds));
        params.put("expireDate", DateTimeUtil.getNowTimeYMD());
        return vipLogDao.getByAccountIds(params);
    }

    @Override
    public Integer getByAccountId(Integer accountId) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(DaoParamConstant.accountId, accountId);
        params.put("expireDate", DateTimeUtil.getNowTimeYMD());
        return vipLogDao.getByAccountId(params);
    }

    @Override
    public VipSta getCountAccountIds(List<Integer> accountIds, String startTime, String endTime) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put(DaoParamConstant.accountIds, StringUtil.getListString(accountIds));
        params.put(DaoParamConstant.startTime, startTime);
        params.put(DaoParamConstant.endTime, endTime);
        return vipLogDao.getCountAccountIds(params);
    }


}
